package configuration

import (
	"encoding/json"
	"fmt"
	"kop/modules/configuration/client"
	"kop/util/log"
)

func init() {

	if err := json.Unmarshal(client.Load("InvestCost"), &InvestCostConfigs); err != nil {
		panic(err)
	}

	log.Info("Load InvestCost.json success.")
}

// 爵位对应消耗
type InvestCostConf struct {
	Peerage      int32 // 爵位
	MaxInvestNum int32 // 投资次数上限
	Coin         int64 // 每次投资银币消耗
	Gold         int32 // 每次投资金币奖励
	LevelUpGold  int32 // 最终投资金币回报
}

var (
	InvestCostConfigs = map[int32]InvestCostConf{}
)

func GetByRoleLevel(roleLevel int32) InvestCostConf {

	var conf, ok = InvestCostConfigs[roleLevel]
	if ok {
		return conf
	}

	panic(fmt.Errorf("roleLevel not found [%d]", roleLevel))
}
